package com.eonmind.ai.mapper;

import com.eonmind.common.contract.data.base.BaseMongoMapper;
import com.eonmind.common.contract.enums.DelEnum;
import com.eonmind.common.contract.enums.StatusEnum;
import com.eonmind.common.provider.entity.ai.AiDrawPlatform;
import com.mongoplus.conditions.query.QueryWrapper;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@Component
public class AiDrawPlatformMapper extends BaseMongoMapper<AiDrawPlatform> {


    public List<AiDrawPlatform> selectPlatformByStatus(Integer status) {
        if (ObjectUtils.isEmpty(status)) {
            return new ArrayList<>();
        }
        QueryWrapper<AiDrawPlatform> eq = createMgoQuery()
                .eq(AiDrawPlatform::getStatus, status)
                .eq(AiDrawPlatform::getDel, DelEnum.UN_DEL.getCode());
        return list(eq);
    }

    public AiDrawPlatform selectPlatformById(Long platformId) {
        if (ObjectUtils.isEmpty(platformId)) {
            return null;
        }
        QueryWrapper<AiDrawPlatform> eq = createMgoQuery()
                .eq(AiDrawPlatform::getId, platformId)
                .eq(AiDrawPlatform::getDel, DelEnum.UN_DEL.getCode())
                .eq(AiDrawPlatform::getStatus, StatusEnum.OPENED.getCode());
        return one(eq);
    }

    public List<AiDrawPlatform> selectAllByIds(Set<Long> platformIds) {
        if (ObjectUtils.isEmpty(platformIds)) {
            return new ArrayList<>();
        }
        QueryWrapper<AiDrawPlatform> eq = createMgoQuery()
                .in(AiDrawPlatform::getId, platformIds)
                .eq(AiDrawPlatform::getDel, DelEnum.UN_DEL.getCode())
                .eq(AiDrawPlatform::getStatus, StatusEnum.OPENED.getCode());
        return list(eq);
    }
}
